﻿using GrapeCity.Forguncy.Commands;
using GrapeCity.Forguncy.Plugin;
using Qdrant.Client.Grpc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QdrantConnector
{
    [Icon("pack://application:,,,/QdrantConnector;component/Resources/Icon.png")]
    [Designer("QdrantConnector.Designer.QdrantConnectorServerCommandDesigner, QdrantConnector")]
    [Category("Qdrant向量数据库")]
    [OrderWeight(810)]
    public class DeleteCollection : BaseQdrantOp
    {
        public override async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
        {
            var client = await getQrantClient(dataContext);
            var collectionName = await getCollectionName(dataContext);

            dataContext.Log.AppendLine($"开始从Qdrant中删除集合【{collectionName}】...");
            var tick = DateTime.Now;


            await client.DeleteCollectionAsync(
                collectionName: collectionName
            );

            dataContext.Log.AppendLine($"Qdrant删除集合【{collectionName}】成功，耗时：{(DateTime.Now - tick).TotalMilliseconds}ms");

            return new ExecuteResult();
        }

        public override string ToString()
        {
            return "Qdrant删除集合";
        }
    }


}
